package cn.zt.config;

import cn.zt.interceptor.LoginInterceptor;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

import javax.annotation.Resource;

@Configuration
public class WebConfig implements WebMvcConfigurer {

    @Resource
    private LoginInterceptor loginInterceptor;

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        // 注册TokenInterceptor，并指定要拦截的路径
        registry.addInterceptor(loginInterceptor)
                .addPathPatterns("/order/**", "/manage/**", "/select/order/**") // 拦截所有以 /api 开头的请求
                .excludePathPatterns("/login", "/select/flight"); // 排除登录和注册接口
    }
}
